package cn.itsource.ymjs.controller;

import cn.itsource.ymjs.doc.CourseDoc;
import cn.itsource.ymjs.query.CourseDocQuery;
import cn.itsource.ymjs.service.ICourseDocService;
import cn.itsource.ymjs.result.JSONResult;
import cn.itsource.ymjs.result.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/courseDoc")
public class CourseDocController {

    @Autowired
    private ICourseDocService courseDocService;
    //批量添加
    @PostMapping("/add")
//    @PreAuthorize("hasAuthority('courseDoc:batchAdd')")
    public JSONResult batchAdd(@RequestBody List<CourseDoc> courseDocs){
        return courseDocService.batchAdd(courseDocs);
    }

    //批量删除
    @PostMapping("/del")
//    @PreAuthorize("hasAuthority('courseDoc:batchDel')")
    public JSONResult batchDel(@RequestBody List<Long> ids){
        return courseDocService.batchDel(ids);
    }

    @PostMapping("/queryCourses")
//    @PreAuthorize("isAnonymous()") //匿名访问
    public PageList<CourseDoc> queryPageData(@RequestBody CourseDocQuery query){
        return  courseDocService.queryPageData(query);
    }
}
